package com.le.tester.tip.generateticketno;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * createTime：2022/9/13 17:01
 * description：GenerateTicketNoTask
 */
public class GenerateTicketNoTask implements Runnable {
    @Override
    public void run() {
        System.out.println(this.createTicketNo(50));
    }

    public String createTicketNo(Integer groupId) {
        String az = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        List<String> azl = new ArrayList<>();
        for (int i = 0; i < az.length(); i++) {
            azl.add(az.substring(i, i + 1));
        }

        int ss = groupId % 26;
        String prefix = azl.get(ss);
        int no = 99999;
        no = new AtomicInteger(no).incrementAndGet();
        String suffix = String.format("%04d", no);

        return prefix + suffix;
    }
}
